package com.wenhao.mi;

import java.util.Scanner;

/**
 * 赛马网的输入输出是不是有病？？？？？
 * @author Wenhao Tong
 * @create 2021-09-01 19:16
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int m = Integer.parseInt(s.substring(s.indexOf('=') + 1,s.indexOf(',')));
        int n = Integer.parseInt(s.substring(s.lastIndexOf('=') + 1));
        String a = scanner.nextLine();
        String b = scanner.nextLine();
        String[] splitA = a.split(",");
        String[] splitB = b.split(",");
        int[] A = new int[splitA.length];
        int[] B = new int[splitB.length];
        for (int i = 0;i < A.length;i++) {
            A[i] = Integer.parseInt(splitA[i]);
        }
        for (int i = 0;i < B.length;i++) {
            B[i] = Integer.parseInt(splitB[i]);
        }
        int indexA = 0;
        int indexB = 0;
        while (indexA < A.length && indexB < B.length) {
            if (A[indexA] <= B[indexB]) {
                System.out.print(A[indexA++] + " ");
            } else {
                System.out.print(B[indexB++] + " ");
            }
        }
        while (indexA < A.length) {
            System.out.print(A[indexA++] + " ");
        }
        while (indexB < B.length) {
            System.out.print(B[indexB++] + " ");
        }
    }
}
